// house_pkg/pages/room/index.ts
Page({
  /**
   * 页面的初始数据
   */
  data: {
    point:'',//小区
    building:'',//单元/号楼
    rooms:[],//房间数组
  },
  onLoad({point,building}){
    this.fakeData(point,building)
  },
  fakeData(point,building){
    const a = [1,2,3,4]
    const b = [1,2,3,4,5,6]
    // 1.确定房间的数量4-8
    const size = Math.floor(Math.random() * 5) + 4
    const rooms = []
    // 1.2变脸产生房间号
    for (let i = 0;i < size; i++){
      // 1.2.1产生随机楼层(1-20)
      // const floor = Math.floor(Math.random() * 20)
      // 1.2.2 产生随机房间号
      const no = Math.floor(Math.random() * 4) + 1
      // 1.2.3组合房间号
      const room = [i+1,'0',no,'室'].join('')
      // 1.2.5数组去重
      if(rooms.includes(room)) continue
      // 1.2.4把房间放入房间数组中
      rooms.push(room)
    }
    this.setData({
      point,
      building,
      rooms
    })
  },
  goDetail(e){
    const {point,building} = this.data
    wx.navigateTo({
      url: `/house_pkg/pages/form/index?point=${point}&building=${building}&room=${e.mark.room}`,
    })
  }

})